﻿using System;
using System.Collections.Generic;
using System.Text;

namespace GeoFly
{
    public  class SoilLayer
    {
        /// <summary>
        /// 土壤水力传导度系数
        /// </summary>
        public double SL_HK;
        /// <summary>
        /// 土壤剖面稳定下渗率(需计算)
        /// </summary>
        public double SL_StaInfil;
        /// <summary>
        /// 土壤剖面初始下渗率(需计算)
        /// </summary>
        public double SL_InitInfil;
       public double SL_P_Fc;
        /// <summary>
        /// 土壤孔隙率 SL_Por=1-SL_BD/2.65(需计算)
        /// </summary>
        public double SL_Por;
        /// <summary>
        /// 土层每日实际可供水量
        /// </summary>
        public double SL_SW;
        /// <summary>
        /// 土壤水饱和时土层可供水量(mm)
        /// </summary>		
        public double SL_Sat;
        /// <summary>
        /// 枯萎点时土层含水量(mm 水/mm 土壤)
        /// /// </summary>	
        public double SL_Wp;
        /// <summary>
        /// 每mm土壤中达到田间持水量的土层含水率(需计算)
        /// </summary>
        public double SL_FcRatio;
        /// <summary>
        /// 每mm土壤中枯萎点时的土层含水率(需计算)
        /// </summary>
        public double SL_WpRatio;
        public int SL_ID;
        /// <summary>
        /// 土壤分层深度(mm)
        /// </summary>
        public double SL_Z;
        public double SL_BD;	
        public double SL_AWC;
        /// <summary>
        /// 饱和导水率(mm/hr)
        /// </summary>	
        public double SL_Sat_K;

        public double SL_Stable_F;
        /// <summary>
        /// 土壤有机质含量(%)
        /// </summary>
        public double SL_Org_C;
        /// <summary>
        /// Clay比例
        /// </summary>
        public double SL_Clay;
        /// <summary>
        /// Silt比例
        /// </summary>
        public double SL_Silt;
        /// <summary>
        /// Sand比例
        /// </summary>
        public double SL_Sand;
        /// <summary>
        /// Rock比例
        /// </summary>
        public double SL_Rock;
        /// <summary>
        /// 
        /// </summary>
        public double SL_Init_F;
        public bool SL_bFillOK;

        public void CalcSoilPara()
        {
            this.SL_StaInfil = this.SL_Stable_F * this.SL_Sat_K;
            this.SL_InitInfil = this.SL_Init_F * this.SL_Sat_K;
            this.SL_WpRatio=0.4 * this.SL_Clay * this.SL_BD / 100.0;
            
            if (SL_WpRatio <= 0)
                SL_WpRatio = 0.005;
            this.SL_FcRatio = this.SL_WpRatio + this.SL_AWC;
            this.SL_Por=1 - this.SL_BD/ 2.65;
            

            if (SL_FcRatio >= SL_Por)
            {
                SL_FcRatio = SL_Por - 0.05;
                SL_WpRatio = SL_FcRatio - SL_AWC;
                if (SL_WpRatio <= 0)
                {
                    SL_FcRatio = SL_Por * 0.75;
                    SL_WpRatio = SL_Por * 0.25;
                }
            }
        }
    }
}
